home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / amos / ProcLib3_0.lha / Graphics / SIMPLEARC.Amos / SIMPLEARC.amosSourceCode
Encoding:
AMOS Source Code  |  1994-12-17  |  3.2 KB  |  119 lines

  1. MAIN
  2. Procedure MAIN
  3.    'This demo is mainly here to show the speed of the thing.  
  4.    'As you can see the proc is actually faster when used to draw big
  5.    '  circles or ellipses.
  6.    '
  7.    'The white circles are drawn by SimpleArc, the grey ones by AMOS.  
  8.    '
  9.    'Use in the second part of the demo the left mouse button to 
  10.    '  paste an arc on the screen. 
  11.    '
  12.    'Modified by Andy Church to open its own screen and display actual 
  13.    '  times.  Compile it to see it run faster!
  14.    '
  15.    Screen Open 0,320,200,4,0
  16.    Palette $0,$777,$EEE,$AAA
  17.    Flash Off : Curs Off 
  18.    'first the small ones
  19.    Ink 2
  20.    Timer=0
  21.    For I=1 To 20
  22.       SIMPLEARC[100+4*I,100,10,10,0,360]
  23.    Next I
  24.    ST1#=Timer/((50.0-Ntsc*10)*20)
  25.    Ink 3
  26.    Timer=0
  27.    For I=1 To 20
  28.       Ellipse 200+4*I,100,10,10
  29.    Next I
  30.    ST2#=Timer/((50.0-Ntsc*10)*20)
  31.    Wait 50
  32.    'now bigger circles
  33.    Ink 2
  34.    Timer=0
  35.    For I=1 To 20
  36.       SIMPLEARC[70+4*I,100,100,100,0,360]
  37.    Next I
  38.    LT1#=Timer/((50.0-Ntsc*10)*20)
  39.    Ink 3
  40.    Timer=0
  41.    For I=1 To 20
  42.       Ellipse 200+4*I,100,100,100
  43.    Next I
  44.    LT2#=Timer/((50.0-Ntsc*10)*20)
  45.    Pen 0
  46.    Print "Time in seconds needed"
  47.    Print "to draw one circle    "
  48.    Print "                      "
  49.    Print "\\\\\| Time (seconds) "
  50.    Print "-----+--------------- "
  51.    Print "     |     small      "
  52.    Print Using "S_Arc| ##.###         ";ST1#
  53.    Print Using "AMOS | ##.###         ";ST2#
  54.    Print "-----+--------------- "
  55.    Print "     |      big       "
  56.    Print Using "S_Arc| ##.###         ";LT1#
  57.    Print Using "AMOS | ##.###         ";LT2#
  58.    Locate 1,23
  59.    Print "Press left mouse button to continue."
  60.    Curs Off : Cup : Cup 
  61.    Repeat 
  62.    Until Mouse Key=1
  63.    Ink 0
  64.    For I=1 To 200 Step 20
  65.       SIMPLEARC[I,I,I,I,I*2,260]
  66.       SIMPLEARC[321-I,I,I,I,I*2,260]
  67.       SIMPLEARC[I,201-I,I,I,I*2,260]
  68.       SIMPLEARC[321-I,201-I,I,I,I*2,260]
  69.    Next I
  70.    Fade 4 : Wait 60 : Cls 0
  71.    Palette $0,$777,$EEE,$AAA
  72.    Ink 1
  73.    Print "Press right mouse button to quit."
  74.    Repeat 
  75.       X=X Screen(X Mouse)
  76.       Y=Y Screen(Y Mouse)
  77.       Gr Writing 2
  78.       SIMPLEARC[X,Y,80,80,ST,180]
  79.       SIMPLEARC[X,Y,80,80,ST,180]
  80.       SX=Sin(ST)*80
  81.       SY=Cos(ST)*80
  82.       Plot X+SX,Y+SY
  83.       If Mouse Key=1
  84.          Gr Writing 0
  85.          SIMPLEARC[X,Y,80,80,ST,180]
  86.          Add ST,10
  87.          If ST>360 : ST=0 : End If 
  88.       End If 
  89.    Until Mouse Key=2
  90. End Proc
  91. Procedure SIMPLEARC[CX,CY,RX,RY,STDEG,TTOTDEG]
  92.    '--- SimpleArc, by Branko Collin 
  93.    '--- v1.0   20-nov-1993    
  94.    '--- copy and use it as you like 
  95.    '
  96.    'This routine draws an arc, where arc is defined as part 
  97.    'of an ellipse (alas, no fancy bezier stuff).
  98.    '
  99.    ' cx and cy       : coordinates of the center    
  100.    ' rx and ry       : radiuses in x and y directions   
  101.    ' stdeg           : starting point in degrees  
  102.    ' ttotdeg         : length of arc in degrees 
  103.    '
  104.    Degree 
  105.    CUMDEG=STDEG+TTOTDEG
  106.    ' sx and sy are the coords of the starting point 
  107.    SX=Sin(STDEG)*RX
  108.    SY=Cos(STDEG)*RY
  109.    ' so are ex and ey for the end point 
  110.    EX=Sin(STDEG+TTOTDEG)*RX
  111.    EY=Cos(STDEG+TTOTDEG)*RY
  112.    Plot CX+SX,CY+SY
  113.    For I=STDEG/10 To CUMDEG/10
  114.       X=Sin(I*10)*RX
  115.       Y=Cos(I*10)*RY
  116.       Draw To CX+X,CY+Y
  117.    Next I
  118.    Draw To CX+EX,CY+EY
  119. End Proc